/**
 * 
 */
package com.netflexitysolutions.amazonws.sdb.orm.metadata;

/**
 * @author netflexity
 *
 * Contains all the objects and attributes that belong to 
 * &lt;set&gt; or &lt;bag&gt; with one-to-many XML element.
 */
public class ManyToManyMetadata extends CollectionMetadata{

	/**
	 * 
	 */
	public ManyToManyMetadata() {
		setLazy(true);
	}
	
	/* (non-Javadoc)
	 * @see com.netflexitysolutions.amazonws.sdb.orm.metadata.AttributeMetadata#toSimpleDB(java.lang.Object)
	 */
	@Override
	public <T> String toSimpleDB(T record) {
		// Get metadata for manyToMany bean itself.
		ItemMetadata manyToManyItemMetadata = getItemMetadata().getMapping().getItemMetadataByClass(getJavaClass());
		assert(manyToManyItemMetadata != null);
		
		// Get primary key info.
		IdMetadata primaryKeyMetadata = manyToManyItemMetadata.getId();
		assert(primaryKeyMetadata != null);
		
		// Get value.
		return primaryKeyMetadata.toSimpleDB(record);
	}
}
